<?php
namespace app\index\controller;
use think\Db;
use think\Request;
use think\Controller;
class Good extends Controller
{
	public function index(){
		return $this->fetch('good/index');
	}
	public function add(){
		$request=Request::instance();
        $data=$request->post();
        $name=$data['name'];
        $pwd=$data['pwd'];
        $rpwd=$data['rpwd'];
        $sql="insert into good values(null,'$name','$pwd','$rpwd')";
        $res=Db::execute($sql);
        if($res){
          $this->success("添加成功",'show');
        }else{
          $this->error("添加失败");
        }
	}
	public function show(){
		$request=Request::instance();
		$sou=isset($_GET['sou'])?$_GET['sou']:'';
        $list = Db::name('good')->where("name like '%$sou%'")->paginate(5);
        $this->assign('list', $list);
        return $this->fetch('show',['list '=>$list]);
	}
	public function del(){
		$request=Request::instance();
		$id=$_GET['id'];
		$sql="delete from good where id=$id";
	    $res=Db::execute($sql);
        echo 1;
	}
}
?>